//go:build wireinject

package main

import (
	"ebip/internel/ioc"
	"ebip/internel/repository/dao/enterprise_dao"
	"ebip/internel/repository/dao/user_dao"
	"ebip/internel/repository/repo"
	"ebip/internel/service"
	"ebip/internel/service/enterprise_service"
	"ebip/internel/web"
	"ebip/internel/web/handler"
	"ebip/internel/web/middlewares/jwtx"
	"github.com/gin-gonic/gin"

	"github.com/google/wire"
)

// @Description
// @Author 代码小学生王木木

var thirdSet = wire.NewSet()

var codeSet = wire.NewSet(
	handler.NewAuthHandler,
	service.NewIAuthSvc,
	repo.NewAuthRepo,
	user_dao.NewIUserDAO,
)
var userSet = wire.NewSet(
	handler.NewUserHandler,
	service.NewUserService,
	repo.NewUserRepo,
	//user_dao.NewIUserDAO,
)

var excelSet = wire.NewSet(
	handler.NewEnterpriseHandler,
	enterprise_service.NewEnterParserV1,
	service.NewFileService,
	repo.NewEnterpriseRepo,
	enterprise_dao.NewEnterpriseDAO,
)

var webSet = wire.NewSet()

func InitWebServer(path string) *gin.Engine {
	wire.Build(
		ioc.InitConfig,
		ioc.InitRedis,
		ioc.InitDatabase,
		ioc.InitLogger,

		service.NewCaptchaService,
		handler.NewCodeHandler,
		jwtx.NewRedisJWTHandler,
		web.NewRouter,
		ioc.InitMiddleware,
		ioc.InitGin,
		codeSet,
		userSet,
		excelSet,
		handler.NewFileHandler,
		//wire.Struct(new(gin.Engine), "*"),
	)

	return new(gin.Engine)
}
